<template>
  <div class="container">
    <div class="item" v-for="(item, index) in tabs" :key="index">
      <span :class="{ active: currentIndex === index }" @click="choose(index)">{{ item }}</span>
    </div>
  </div>
</template>

<script>
export default {
  emits: ['choose'],
  props: {
    tabs: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      currentIndex: 0
    }
  },
  methods: {
    choose(index) {
      this.currentIndex = index
      this.$emit('choose', index)
    }
  }
}
</script>

<style scoped>
.container {
  display: flex;
  width: 200px;
  margin-top: 20px;
}
.item {
  flex: 1;
  text-align: center;
  border: 1px solid black;
}
.item:hover {
  cursor: pointer;
}
.active {
  border-bottom: 2px solid red;
}
</style>
